home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / cswsk10.zip / tinyftp.frm < prev    next >
Text File  |  1995-07-01  |  13KB  |  451 lines

  1. VERSION 2.00
  2. Begin Form Client 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "FTP Client"
  6.    ClientHeight    =   4185
  7.    ClientLeft      =   1860
  8.    ClientTop       =   1935
  9.    ClientWidth     =   7095
  10.    FontBold        =   0   'False
  11.    FontItalic      =   0   'False
  12.    FontName        =   "MS Sans Serif"
  13.    FontSize        =   8.25
  14.    FontStrikethru  =   0   'False
  15.    FontUnderline   =   0   'False
  16.    Height          =   4875
  17.    Left            =   1800
  18.    LinkTopic       =   "Form1"
  19.    ScaleHeight     =   4185
  20.    ScaleWidth      =   7095
  21.    Top             =   1305
  22.    Width           =   7215
  23.    Begin Socket Socket2 
  24.       Backlog         =   1
  25.       Binary          =   -1  'True
  26.       Blocking        =   -1  'True
  27.       Broadcast       =   0   'False
  28.       BufferSize      =   0
  29.       HostAddress     =   ""
  30.       HostFile        =   ""
  31.       HostName        =   ""
  32.       InLine          =   0   'False
  33.       Interval        =   0
  34.       KeepAlive       =   0   'False
  35.       Left            =   600
  36.       Linger          =   0
  37.       LocalPort       =   0
  38.       LocalService    =   ""
  39.       Peek            =   0   'False
  40.       Protocol        =   0
  41.       RecvLen         =   0
  42.       RemotePort      =   0
  43.       RemoteService   =   ""
  44.       ReuseAddress    =   0   'False
  45.       Route           =   -1  'True
  46.       SendLen         =   0
  47.       TabIndex        =   24
  48.       Timeout         =   0
  49.       Top             =   3600
  50.       Type            =   1
  51.       Urgent          =   0   'False
  52.    End
  53.    Begin Socket Socket1 
  54.       Backlog         =   1
  55.       Binary          =   -1  'True
  56.       Blocking        =   -1  'True
  57.       Broadcast       =   0   'False
  58.       BufferSize      =   0
  59.       HostAddress     =   ""
  60.       HostFile        =   ""
  61.       HostName        =   ""
  62.       InLine          =   0   'False
  63.       Interval        =   0
  64.       KeepAlive       =   0   'False
  65.       Left            =   120
  66.       Linger          =   0
  67.       LocalPort       =   0
  68.       LocalService    =   ""
  69.       Peek            =   0   'False
  70.       Protocol        =   0
  71.       RecvLen         =   0
  72.       RemotePort      =   0
  73.       RemoteService   =   ""
  74.       ReuseAddress    =   0   'False
  75.       Route           =   -1  'True
  76.       SendLen         =   0
  77.       TabIndex        =   23
  78.       Timeout         =   0
  79.       Top             =   3600
  80.       Type            =   1
  81.       Urgent          =   0   'False
  82.    End
  83.    Begin CommandButton CopyButton 
  84.       Caption         =   "Copy"
  85.       Enabled         =   0   'False
  86.       Height          =   375
  87.       Left            =   3840
  88.       TabIndex        =   22
  89.       Top             =   3600
  90.       Width           =   1215
  91.    End
  92.    Begin Frame TransferFrame 
  93.       BackColor       =   &H00C0C0C0&
  94.       Caption         =   "Transfer"
  95.       Height          =   1695
  96.       Left            =   4440
  97.       TabIndex        =   21
  98.       Top             =   1680
  99.       Width           =   2535
  100.       Begin CheckBox BinaryTransfer 
  101.          BackColor       =   &H00C0C0C0&
  102.          Caption         =   "Binary"
  103.          Height          =   255
  104.          Left            =   240
  105.          TabIndex        =   15
  106.          Top             =   1200
  107.          Width           =   855
  108.       End
  109.       Begin OptionButton RemoteTransfer 
  110.          BackColor       =   &H00C0C0C0&
  111.          Caption         =   "To Remote System"
  112.          Height          =   255
  113.          Left            =   240
  114.          TabIndex        =   14
  115.          Top             =   840
  116.          Width           =   2055
  117.       End
  118.       Begin OptionButton LocalTransfer 
  119.          BackColor       =   &H00C0C0C0&
  120.          Caption         =   "To Local System"
  121.          Height          =   375
  122.          Left            =   240
  123.          TabIndex        =   13
  124.          Top             =   430
  125.          Value           =   -1  'True
  126.          Width           =   1935
  127.       End
  128.    End
  129.    Begin Frame FileFrame 
  130.       BackColor       =   &H00C0C0C0&
  131.       Caption         =   "File"
  132.       Height          =   1695
  133.       Left            =   120
  134.       TabIndex        =   20
  135.       Top             =   1680
  136.       Width           =   4215
  137.       Begin TextBox RemoteFile 
  138.          BackColor       =   &H00C0C0C0&
  139.          Height          =   300
  140.          Left            =   1200
  141.          TabIndex        =   12
  142.          Top             =   1080
  143.          Width           =   2775
  144.       End
  145.       Begin TextBox LocalFile 
  146.          BackColor       =   &H00C0C0C0&
  147.          Height          =   300
  148.          Left            =   1200
  149.          TabIndex        =   10
  150.          Top             =   720
  151.          Width           =   2775
  152.       End
  153.       Begin Label RemotePath 
  154.          BackStyle       =   0  'Transparent
  155.          Height          =   300
  156.          Left            =   1200
  157.          TabIndex        =   8
  158.          Top             =   360
  159.          Width           =   2775
  160.       End
  161.       Begin Label Label7 
  162.          BackStyle       =   0  'Transparent
  163.          Caption         =   "Directory:"
  164.          Height          =   255
  165.          Left            =   120
  166.          TabIndex        =   7
  167.          Top             =   360
  168.          Width           =   855
  169.       End
  170.       Begin Label Label6 
  171.          BackStyle       =   0  'Transparent
  172.          Caption         =   "&Remote:"
  173.          Height          =   255
  174.          Left            =   120
  175.          TabIndex        =   11
  176.          Top             =   1080
  177.          Width           =   735
  178.       End
  179.       Begin Label Label5 
  180.          BackStyle       =   0  'Transparent
  181.          Caption         =   "&Local:"
  182.          Height          =   255
  183.          Left            =   120
  184.          TabIndex        =   9
  185.          Top             =   720
  186.          Width           =   615
  187.       End
  188.    End
  189.    Begin CommandButton ActionButton 
  190.       Caption         =   "Connect"
  191.       Height          =   375
  192.       Left            =   2160
  193.       TabIndex        =   17
  194.       Top             =   3600
  195.       Width           =   1215
  196.    End
  197.    Begin Frame UserFrame 
  198.       BackColor       =   &H00C0C0C0&
  199.       Caption         =   "User"
  200.       Height          =   1455
  201.       Left            =   3600
  202.       TabIndex        =   19
  203.       Top             =   120
  204.       Width           =   3375
  205.       Begin TextBox Password 
  206.          BackColor       =   &H00C0C0C0&
  207.          Height          =   300
  208.          Left            =   1080
  209.          PasswordChar    =   "*"
  210.          TabIndex        =   6
  211.          Top             =   840
  212.          Width           =   1935
  213.       End
  214.       Begin TextBox UserName 
  215.          BackColor       =   &H00C0C0C0&
  216.          Height          =   300
  217.          Left            =   1080
  218.          TabIndex        =   4
  219.          Top             =   480
  220.          Width           =   1935
  221.       End
  222.       Begin Label Label4 
  223.          BackColor       =   &H00FFFFFF&
  224.          BackStyle       =   0  'Transparent
  225.          Caption         =   "&Password:"
  226.          Height          =   255
  227.          Left            =   120
  228.          TabIndex        =   5
  229.          Top             =   840
  230.          Width           =   975
  231.       End
  232.       Begin Label Label3 
  233.          BackStyle       =   0  'Transparent
  234.          Caption         =   "&Username:"
  235.          Height          =   255
  236.          Left            =   120
  237.          TabIndex        =   3
  238.          Top             =   480
  239.          Width           =   975
  240.       End
  241.    End
  242.    Begin Frame RemoteFrame 
  243.       BackColor       =   &H00C0C0C0&
  244.       Caption         =   "System"
  245.       Height          =   1455
  246.       Left            =   120
  247.       TabIndex        =   18
  248.       Top             =   120
  249.       Width           =   3375
  250.       Begin ComboBox Hostname 
  251.          BackColor       =   &H00C0C0C0&
  252.          Height          =   300
  253.          Left            =   1200
  254.          Sorted          =   -1  'True
  255.          TabIndex        =   0
  256.          Top             =   480
  257.          Width           =   1935
  258.       End
  259.       Begin TextBox IPAddress 
  260.          BackColor       =   &H00C0C0C0&
  261.          Height          =   300
  262.          Left            =   1200
  263.          TabIndex        =   2
  264.          Top             =   840
  265.          Width           =   1575
  266.       End
  267.       Begin Label Label2 
  268.          BackStyle       =   0  'Transparent
  269.          Caption         =   "IP &Address:"
  270.          Height          =   255
  271.          Left            =   120
  272.          TabIndex        =   1
  273.          Top             =   840
  274.          Width           =   1095
  275.       End
  276.       Begin Label Label1 
  277.          BackStyle       =   0  'Transparent
  278.          Caption         =   "&Hostname:"
  279.          Height          =   255
  280.          Left            =   120
  281.          TabIndex        =   16
  282.          Top             =   480
  283.          Width           =   975
  284.       End
  285.    End
  286.    Begin Menu FileMenu 
  287.       Caption         =   "&File"
  288.       Begin Menu ExitApp 
  289.          Caption         =   "E&xit"
  290.       End
  291.    End
  292. End
  293. Option Explicit
  294.  
  295. Sub ActionButton_Click ()
  296.     If Not Socket1.Connected Then
  297.         ActionButton.Enabled = False
  298.         ActionButton.Default = False
  299.         Client.MousePointer = 11
  300.         If Not FTPConnect(Trim$(HostName.Text)) Then
  301.             ActionButton.Enabled = True
  302.             ActionButton.Default = True
  303.             Exit Sub
  304.         End If
  305.         If Not FTPLogin(Trim$(UserName.Text), Trim$(Password.Text)) Then
  306.             Client.MousePointer = 0
  307.             Socket1.Action = SOCKET_CLOSE
  308.             ActionButton.Enabled = True
  309.             ActionButton.Default = True
  310.             Exit Sub
  311.         End If
  312.         Client.MousePointer = 0
  313.         FTPGetDirectory
  314.         ActionButton.Caption = "Disconnect"
  315.         ActionButton.Enabled = True
  316.         CopyButton.Enabled = True
  317.     Else
  318.         Socket1.Action = SOCKET_CLOSE
  319.         ActionButton.Caption = "Connect"
  320.         ActionButton.Default = True
  321.         CopyButton.Enabled = False
  322.         HostName.SetFocus
  323.     End If
  324. End Sub
  325.  
  326. Sub CopyButton_Click ()
  327.     Dim SrcFile As String, DstFile As String
  328.     
  329.     CopyButton.Enabled = False
  330.     Client.MousePointer = 11
  331.  
  332.     If LocalTransfer.Value Then
  333.         SrcFile = Trim$(RemoteFile.Text)
  334.         DstFile = Trim$(LocalFile.Text)
  335.         If Not FTPGetFile(SrcFile, DstFile) Then
  336.             Client.MousePointer = 0
  337.             MsgBox "Could not copy remote file"
  338.         End If
  339.     Else
  340.         SrcFile = Trim$(LocalFile.Text)
  341.         DstFile = Trim$(RemoteFile.Text)
  342.         If Not FTPPutFile(SrcFile, DstFile) Then
  343.             Client.MousePointer = 0
  344.             MsgBox "Could not copy local file"
  345.         End If
  346.     End If
  347.     
  348.     CopyButton.Enabled = True
  349.     Client.MousePointer = 0
  350. End Sub
  351.  
  352. Sub ExitApp_Click ()
  353.     Unload Client
  354. End Sub
  355.  
  356. Sub Form_Load ()
  357.     Dim Host As String
  358.  
  359.     '
  360.     ' Initialize hostname combo box
  361.     '
  362.     On Error Resume Next
  363.     Socket1.HostFile = "HOSTS"
  364.     If Err = 0 Then
  365.         Host$ = Socket1.GetFirstHost
  366.         While Host$ <> ""
  367.             HostName.AddItem Host$
  368.             Host$ = Socket1.GetNextHost
  369.         Wend
  370.     End If
  371.     Socket1.HostFile = ""
  372.  
  373.     '
  374.     ' Initialize the other controls
  375.     '
  376.     ActionButton.Caption = "Connect"
  377.     ActionButton.Default = True
  378.     ActionButton.Enabled = False
  379. End Sub
  380.  
  381. Sub Form_Unload (Cancel As Integer)
  382.     If Socket1.Connected Then Socket1.Action = SOCKET_CLOSE
  383.     If Socket2.Listening Or Socket2.Connected Then Socket2.Action = SOCKET_CLOSE
  384.     End
  385. End Sub
  386.  
  387. Sub Hostname_Change ()
  388.     If (Len(HostName.Text) > 0 Or Len(IPAddress.Text) > 0) And Len(UserName.Text) > 0 Then
  389.         ActionButton.Enabled = True
  390.     Else
  391.         ActionButton.Enabled = False
  392.     End If
  393. End Sub
  394.  
  395. Sub Hostname_GotFocus ()
  396.     HostName.SelStart = 0
  397.     HostName.SelLength = Len(HostName.Text)
  398. End Sub
  399.  
  400. Sub Hostname_LostFocus ()
  401.     On Error Resume Next
  402.  
  403.     Socket1.HostName = Trim(HostName.Text)
  404.     IPAddress.Text = Socket1.HostAddress
  405.     If Err = WSANO_DATA Then IPAddress.Text = ""
  406.     Exit Sub
  407. End Sub
  408.  
  409. Sub IPAddress_Change ()
  410.     If Len(HostName.Text) > 0 Or Len(IPAddress.Text) > 0 Then
  411.         ActionButton.Enabled = True
  412.     Else
  413.         ActionButton.Enabled = False
  414.     End If
  415. End Sub
  416.  
  417. Sub IPAddress_GotFocus ()
  418.     IPAddress.SelStart = 0
  419.     IPAddress.SelLength = Len(IPAddress.Text)
  420. End Sub
  421.  
  422. Sub IPAddress_LostFocus ()
  423.     On Error Resume Next
  424.     
  425.     Socket1.HostAddress = Trim(IPAddress.Text)
  426.     HostName.Text = Socket1.HostName
  427.     If Err = WSANO_DATA Then
  428.         MsgBox "That IP address is invalid"
  429.         Socket1.HostAddress = ""
  430.     End If
  431.     Exit Sub
  432. End Sub
  433.  
  434. Sub Socket1_Close ()
  435.     Socket1.Action = SOCKET_CLOSE
  436.     ActionButton.Caption = "Connect"
  437.     ActionButton.Default = True
  438.     CopyButton.Enabled = False
  439.     MsgBox "Remote server closed control connection"
  440. End Sub
  441.  
  442. Sub UserName_Change ()
  443.     If Len(UserName.Text) > 0 And (Len(HostName.Text) > 0 Or Len(IPAddress.Text) > 0) Then
  444.         ActionButton.Enabled = True
  445.     Else
  446.         ActionButton.Enabled = False
  447.     End If
  448.  
  449. End Sub
  450.  
  451.